#include <stdio.h>

int main( )
{
    __int64 n;
    while ( scanf("%I64d", &n) != EOF )
    {
        n++;
        int i, j;
        __int64 a = 1, b;
        bool t = false;
        for ( i = 0; ; i++ )
        {
            b = 1;
            if ( a > n ) break;
            for ( j = 0; ; j++ )
            {
                if ( a * b > n ) break;
                if ( a * b == n ) t = true;
                b *= 3;
            }
            a *= 2;
        }
        if ( n - 1 == 0 ) t = false;
        if ( t )
            printf("YES!\n");
        else printf("NO!\n");
    }
    return 0;
}
